package com.usian.article.controller;

import com.usian.apis.article.ArticleHomeControllerApi;
import com.usian.article.service.ApArticleService;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController implements ArticleHomeControllerApi {

    @Autowired
    private ApArticleService apArticleService;

    /**
     * app 默认首页列表查询
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load((short)2,dto);
    }

    /**
     * app 查询更多
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/loadMore")
    public ResponseResult loadMore(ArticleHomeDto dto) {
        return apArticleService.load((short)2,dto);
    }

    /**
     * app 查询最新
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/loadNews")
    public ResponseResult loadNews(ArticleHomeDto dto) {
        return apArticleService.load((short)1,dto);
    }
}
